package org.sjs.dreamfly.biz.site

import android.content.Intent
import android.os.Bundle
import org.sjs.dreamfly.R
import org.sjs.dreamfly.common.base.BaseActivity
import org.sjs.dreamfly.biz.site.SiteFragment

class SiteActivity : BaseActivity() {

    private lateinit var siteFragment: SiteFragment

    override fun requireLayoutId(): Int { return R.layout.activity_site }

    override fun onLoadData(savedInstanceState: Bundle?, newIntent: Intent?) {
        siteFragment = SiteFragment.newInstance(intent.getStringExtra("url")?:"")
        if (savedInstanceState == null) {
            supportFragmentManager.beginTransaction()
                .replace(R.id.container, siteFragment)
                .commitNow()
        }
    }

    override fun onBindViews() {}
    override fun onInitViews() {}
    override fun onBackPressed() {
        if (siteFragment.canGoBack()) {
            siteFragment.goBack()
        } else {
            onBackPressedDispatcher.onBackPressed()
        }
    }
}